package com.cn.wanxi.service;

import com.cn.wanxi.dao.CompanyDao;
import com.cn.wanxi.model.CompanyModel;

/**
 * 得到具体对象的值
 */
public class CompanyService {
    private CompanyModel companyModel = null;
//    private CompanyModel companyModel = new CompanyModel();

    /**
     * 提供给别人调用，并得到当前companyModel对象的值
     *
     * @return
     */
    public CompanyModel getCompanyModel() {
        return companyModel;
    }

    /**
     * 提供给别人调用，让它来对当前的对象赋值
     *
     * @param companyModel
     */
    public void setCompanyModel(CompanyModel companyModel) {
//        怎么拿到dao层的数据
        CompanyDao companyDao = new CompanyDao();
        companyModel.setLogo(companyDao.getLogo());
        companyModel.setPhone(companyDao.getPhone());
        companyModel.setNet(CompanyDao.NET);
        companyModel.setEmail(CompanyDao.EMAIL);
        companyModel.setAddress(CompanyDao.ADDRESS);
        companyModel.setLinePhone(CompanyDao.LINE_PHONE);
        companyModel.setVersion(CompanyDao.VERSION);
        this.companyModel = companyModel;
    }

    /**
     * 没有传参数
     *
     * @return
     */
    public CompanyModel setCompanyModel() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        companyModel.setLogo(companyDao.getLogo());
        companyModel.setPhone(companyDao.getPhone());
        companyModel.setNet(CompanyDao.NET);
        companyModel.setEmail(CompanyDao.EMAIL);
        companyModel.setAddress(CompanyDao.ADDRESS);
        companyModel.setLinePhone(CompanyDao.LINE_PHONE);
        companyModel.setVersion(CompanyDao.VERSION);
        return companyModel;
    }
}
